package org.thanos.demo.http.filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import org.thanos.demo.http.session.SessionManageService;
import reactor.core.publisher.Mono;

@Component
public class AuthFilter implements WebFilter {

    @Autowired
    private SessionManageService sessionManageService;

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        ServerHttpResponse response = exchange.getResponse();
        String token = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);

        return chain.filter(exchange);
    }
}
